﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace MSTestExamples
{
	public class MyController : Controller
	{
		public string ShouldBeSet { get; set; }
	}

	public class MyD2Controller : MyController
	{

	}

	public class AccountController : Controller
	{
		public ActionResult Index()
		{
			return View();
		}

		public ActionResult Register()
		{
			return View();
		}

		public ActionResult Login()
		{
			return View();
		}

		public ActionResult Edit()
		{
			return View();
		}
	}

	public interface IRepository<T>
	{
		T Save<T>(T toSave);
	}

	public class CustomerService
	{
		IRepository<Account> AccountRepository;
		public CustomerService(IRepository<Account> accountRepository)
		{
			AccountRepository = accountRepository;
		}

		public virtual void CloseAccount(Account acct)
		{
			if(!acct.IsActive)
				throw new Exception("You can only close active accounts");

			acct.IsActive = false;
			AccountRepository.Save(acct);
		}
	}

	public class Account
	{
		public virtual int Id {get; set;}
		public virtual User CreatedBy { get; set; }
		public virtual IList<User> SalesPeople { get; set; }
		public virtual bool IsActive { get; set; }
	}

	public class User
	{
		public virtual int Id { get; set; }
		public virtual string AuthName { get; set; }
		public virtual string FirstName { get; set; }
		public virtual string LastName { get; set; }
	}
}
